Modern object-oriented programming languages (OOPL), such as, e.g, Java and C++, are polymorphic and provide many inherent runtime supports, such as, e.g., reflection, garbage collection, language level synchronization, runtime object identification, and the like.
Some runtime support systems may reserve two or more words per object for runtime support. These two or more words may be known as an object header. The first word in a conventional object header is a pointer (i.e., a reference to an address) to a structure of class information for, e.g., virtual method dispatching. The second word in a conventional object header is a word that is dedicated or multiplexed for other runtime supports, such as, e.g., thin-locking, language level synchronization, object hash code, garbage collection and reflection for fast runtime type checking.
Such two-word object headers may be acceptable for desktop and server applications and other applications where space overhead is not a concern. However, these two-word object headers may be less acceptable for embedded and mobile systems that have a strong demand on small heap size, for example.
Attempts to reduce object header overhead have been made by implementing one-word object headers, for example. In one type of one-word object header, a number of bits of the first word stores an index of an array of class information instead of a pointer to the class information. Storing an index of an array of class information can lead to slow virtual method dispatching. Furthermore, in such an array design, the number of bits allocated for the index is controlled. Controlling the allocation of bits restricts how many classes can be loaded.
Other one-word object header designs store a pointer chasing to a so-called near object in the first word. This pointer, in turn, points to the class information. When synchronization or hash code information is requested for the relevant object, a “fat” near object is created to accommodate more information and the object header is redirected to the new near object. This pointer chasing process introduces more complexity in managing the object header and requires an additional pointer chasing for each virtual method dispatch.